package com.foreverwin.jzymes.production.resource.controller;

import com.foreverwin.jzymes.common.util.CommonMethods;
import com.foreverwin.jzymes.framework.base.AjaxResult;
import com.foreverwin.jzymes.framework.exception.BusinessException;
import com.foreverwin.jzymes.production.resource.domain.ResourceRepairLog;
import com.foreverwin.jzymes.production.resource.service.IResourceRepairLogAdviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/resourceRepair")
public class ResourceRepairController {

    @Autowired
    IResourceRepairLogAdviceService resourceRepairLogAdviceService;

    @RequestMapping("/findResourceRepair")
    public AjaxResult findResourceRepair( @RequestParam String resource ){
        try{
            String site = CommonMethods.getSite();

            ResourceRepairLog resourceRepairLog = resourceRepairLogAdviceService.findOpenResourceRepairLog( site, resource );
            return AjaxResult.returnSuccess().put( "value", resourceRepairLog );
        }catch ( BusinessException e ){
            return AjaxResult.returnError( e.getMessage() );
        }
    }
}
